// CLIENT SIDE

// Removes Default HUD
/*
function TDMHideDefaultHUD(name)
	for k, v in pairs({"CHudHealth", "CHudBattery", "CHudAmmo", "CHudSecondaryAmmo", "CHudDeathNotice"}) do
		if name == v then return false end
	end
end
hook.Add("HUDShouldDraw", "TDMHideDefaultHUD", TDMHideDefaultHUD)
*/
COLOR_WHITE = (Color(255,255,255,255))
COLOR_RED = (Color(255,0,0,255))
COLOR_BLUE = (Color(0,0,255,255))
COLOR_GREEN = (Color(0,255,0,255))
COLOR_BLACK = (Color(0,0,0,255))
COLOR_ORANGE = (Color(255,102,51,255))
COLOR_AQUA = (Color(0,138,184,255))
GetXPPoints = 0
GetIfTimerSet = 0
pl = nil


// Our Hud
function TDMRoundedBoxHook()
// Player Information
draw.RoundedBox( 8, 5, 5, 220, 114, Color(0, 0, 0, 180) )

draw.SimpleTextOutlined( "Player Name:", "ChatFont", 15, 10, COLOR_WHITE, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )
draw.SimpleTextOutlined( LocalPlayer():Nick(), "ChatFont", 108, 10, team.GetColor(LocalPlayer():Team()), TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )

draw.SimpleTextOutlined( "Player Score:", "ChatFont", 15, 25, COLOR_WHITE, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )
draw.SimpleTextOutlined( LocalPlayer():Frags(), "ChatFont", 107, 25, COLOR_RED, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )

draw.SimpleTextOutlined( "Team Name:", "ChatFont", 15, 40, COLOR_WHITE, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )
draw.SimpleTextOutlined( team.GetName(LocalPlayer():Team()), "ChatFont", 101, 40, team.GetColor(LocalPlayer():Team()), TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )

draw.SimpleTextOutlined( "Team Score:", "ChatFont", 15, 55, COLOR_WHITE, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )
draw.SimpleTextOutlined( team.GetScore(LocalPlayer():Team()), "ChatFont", 100, 55, COLOR_RED, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )

draw.SimpleTextOutlined( "Kills:", "ChatFont", 15, 70, COLOR_WHITE, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )
draw.SimpleTextOutlined( LocalPlayer():Frags(), "ChatFont", 50, 70, COLOR_RED, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )

draw.SimpleTextOutlined( "Deaths:", "ChatFont", 15, 85, COLOR_WHITE, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )
draw.SimpleTextOutlined( LocalPlayer():Deaths(), "ChatFont", 69, 86, COLOR_RED, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )

--XP SYSTEM?
draw.SimpleTextOutlined( "Points:", "ChatFont", 15, 100, COLOR_WHITE, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )
function TDMGETPOINTS(data)
GetXPPoints = data:ReadString()
end
usermessage.Hook("TDMGETPOINTS",TDMGETPOINTS)
draw.SimpleTextOutlined( GetXPPoints, "ChatFont", 64, 101, COLOR_RED, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )

-- Health/Armour
draw.SimpleTextOutlined( "Health:", "HUDNumber", 460, 0, COLOR_RED, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )
draw.SimpleTextOutlined( LocalPlayer():Health(), "HUDNumber", 570, 0, COLOR_RED, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )

draw.SimpleTextOutlined( "Armour:", "HUDNumber", 460, 35, COLOR_BLUE, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )
draw.SimpleTextOutlined( LocalPlayer():Armor(), "HUDNumber", 585, 35, COLOR_BLUE, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )

-- Timer/Counter/Down/Thing/Slash
function TDMGETIFTIMER(data)
GetIfTimer = data:ReadShort()
GetIfTimerSet = data:ReadShort()
end
usermessage.Hook("TDMGETIFTIMER",TDMGETIFTIMER)

if GetIfTimer == 0 then
else
	draw.SimpleTextOutlined( "Timer:", "TargetID", 235, 95, COLOR_ORANGE, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )
	if (GetIfTimerSet - math.Round(CurTime())) > 60 then
	draw.SimpleTextOutlined( math.Round((GetIfTimerSet - math.Round(CurTime())) / 60), "TargetID", 280, 95, COLOR_WHITE, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )
	--draw.SimpleTextOutlined( math.Round((GetIfTimerSet - math.Round(CurTime())) / 60), "TargetID", 280, 95, COLOR_WHITE, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )
	else
	draw.SimpleTextOutlined( (GetIfTimerSet - CurTime()), "TargetID", 280, 95, COLOR_WHITE, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )
	end
end

// Team Customs
draw.RoundedBox( 8, 231, 5, 220, 85, Color(0, 0, 0, 180) )

draw.SimpleTextOutlined( "~Top Team~", "ChatFont", 295, 10, COLOR_WHITE, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )
draw.SimpleTextOutlined( "Team: ", "ChatFont", 238, 25, COLOR_WHITE, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )
draw.SimpleTextOutlined( "Score: ", "ChatFont", 238, 40, COLOR_WHITE, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )
draw.SimpleTextOutlined( "Current MVP: ", "ChatFont", 238, 55, COLOR_WHITE, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )
draw.SimpleTextOutlined( "MVP's Score: ", "ChatFont", 238, 70, COLOR_WHITE, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )
Teams = team.GetAllTeams()[1]
for k,v in pairs(team.GetAllTeams()) do
	if k != 0 and k < 1000 then
		if team.GetScore(k) >= team.GetScore(Teams) then
		if team.GetScore(k) == 0 then
		
		else
			Teams = k
			
			pl = player.GetAll()[1]
			for l,r in pairs(player.GetAll()) do
				if r:Frags() > pl:Frags() then
					pl = r 
				end
			end
		end
		end
	end
end
draw.SimpleTextOutlined( team.GetName(Teams), "ChatFont", 282, 26, team.GetColor(Teams), TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )
draw.SimpleTextOutlined( team.GetScore(Teams), "ChatFont", 283, 41, COLOR_RED, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )
if pl != nil then
draw.SimpleTextOutlined( pl:Nick(), "ChatFont", 328, 55, team.GetColor(pl:Team()), TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )
draw.SimpleTextOutlined( pl:Frags(), "ChatFont", 326, 71, COLOR_RED, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )
end


// Weapon Information - MUST BE AT THE BOTTOM OF THE FILE
if !LocalPlayer():IsValid() then return end
if !LocalPlayer():Alive() then 
draw.SimpleTextOutlined( "YOU ARE DEAD!", "HUDNumber", 460, 70, COLOR_RED, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )
else
if LocalPlayer():GetActiveWeapon() == NULL || LocalPlayer():GetActiveWeapon() == nil then return end
local Weapon = (LocalPlayer():GetActiveWeapon():GetClass())
local Weapon = string.upper(Weapon)
local Weapon = string.gsub(Weapon,"WEAPON","")
local Weapon = string.gsub(Weapon,"CS","")
local Weapon = string.gsub(Weapon,"_","")
local WeaponClip = LocalPlayer():GetActiveWeapon():Clip1()
local WeaponClipAmmo = LocalPlayer():GetAmmoCount(LocalPlayer():GetActiveWeapon():GetPrimaryAmmoType())
draw.SimpleTextOutlined( Weapon.." : "..WeaponClip.."/"..WeaponClipAmmo, "HUDNumber", 460, 70, COLOR_WHITE, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0 )
end
end
hook.Add("HUDPaint", "TDMRoundedBoxHud", TDMRoundedBoxHook)